<include file="header" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<body>
<div class="wraper">
    <div class="top">
        <a href="javascript:history.go(-1);" class="iconfont icon-zuo pull-left"></a>
        <span class="pull-left">电费充值</span>
        <a href="javascript:void(0);" class="iconfont icon-caidan-copy pull-left text-right"></a>
        <div class="sub-menu">
            <a href="{BEESCRM::U('base/ecs/chargeLog',array('ecs_id'=>$ecs_id))}" class="sub-menu-list"><span class="iconfont icon-czjl"></span>历史记录</a>
            <a href="{BEESCRM::U('base/ecs/eleremind',array('ecs_id'=>$ecs_id))}" class="sub-menu-list"><span class="iconfont icon-tixing"></span> 提醒设置</a>
            <if condition="$account_id eq 60">
                <a href="{BEESCRM::U('base/ecs/refund',array('ecs_id'=>$ecs_id))}" class="sub-menu-list"><span class="iconfont icon-warn"></span>退款</a>
            </if>
        </div>
    </div>
    <div class="electric-note tb-mode">
        <div class="tb-cell">
	        <div class="eleInfo">
	        </div>
        </div>
	    <if condition="1 eq 8">
		    <div class="tb-cell search-btn text-right hsd-close" ><a href="javascript:void(0)">电量查询</a></div>
		   <else/>
            <div class="tb-cell search-btn text-right"><a href="{BEESCRM::U('base/ecs/query',array('ecs_id'=>$ecs_id))}">电量查询</a></div>
	    </if>
    </div>
    <div class="margin-top">
        <p class="form-box">
            <select id="community">
                <option value="0">请选择所在生活区</option>
                <volist name="communityList" id="vo">
                    <option value="{BEESCRM:$vo.community_id}" <if condition="$vo['community_id'] eq $community_id" >selected="selected"</if>>{BEESCRM:$vo.community_name}</option>
                </volist>
            </select>
            <span class="triangle"></span>
        </p>
        <p class="form-box">
            <select id="building">
                <option value="0">请选择楼幢</option>
	            <if condition="$building">
		            <volist name="building" id="vo">
			            <option value="{BEESCRM:$vo.building_id}"<if condition="$building_id eq $vo['building_id']">selected="selected"</if>>{BEESCRM:$vo.building_name}</option>
		            </volist>
	            </if>
            </select>
            <span class="triangle"></span>
        </p>
	    <p class="form-box">
            <select id="floor">
                <option value="0">请选择楼层</option>
	            <if condition="$floor">
		            <volist name="floor" id="vo">
			            <option value="{BEESCRM:$vo.floor_id}"<if condition="$floor_id eq $vo['floor_id']">selected="selected"</if>>{BEESCRM:$vo.floor_name}</option>
		            </volist>
	            </if>
            </select>
            <span class="triangle"></span>
        </p>
        <p class="form-box">
	        <select id="room">
		        <option value="0">请选择<if condition="$ecs_id eq 9">商户<else/>寝室</if></option>
		        <if condition="$room">
			        <volist name="room" id="vo">
				        <option value="{BEESCRM:$vo.room_id}"<if condition="$room_id eq $vo['room_id']">selected="selected"</if>>{BEESCRM:$vo.room_name}</option>
			        </volist>
		        </if>
	        </select>
	        <span class="triangle"></span>
        </p>
    </div>
    <div class="contain-box margin-top">
        <p class="amount">充值金额</p>
        <div class="tab-prize clearfix">
	        <volist name="amount" id="vo">
		        <span class="option sub-list <if condition="$key eq 0">checked</if>" data-amount="{BEESCRM:$vo}">{BEESCRM:$vo}元</span>
	        </volist>
        </div>
    <p class="amount">其他金额</p>
    <input type="text" style="border: 1px solid #ccc;margin-top: 10px;" onpaste="return false;"  name="others"  onfocus="removeChecked()" onkeyup="value=value.replace(/[^\d.]/g,'')" id="other">
    </div>
    <if condition="$memo">
		<div class="contain-box margin-top">
			<p class="amount" style="color: red;">温馨提示:</p>
			<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{BEESCRM:$memo}</p>
		</div>
	</if>

    <div class="btn-box">
        <a href="javascript:void(0);" class="btn save">立即充值</a>
    </div>
	<if condition="$account_id eq 5">
    <div class="pop-box">
        <div class="main text-center">
            <div class="header"><img src="/assets/base/ecs/images/pop-bg.png"/></div>
            <div class="text-content">
                <p class="text-16">温馨提示</p>
                <p class="text-gray">请选择缴费寝室所在的楼幢</p>
            </div>
            <a href="/base/ips/index/ips_id/8?v={BEESCRM:$time}" class="btn btn-blue">给B1-B10,C1-C12,A3-A7幢缴电费</a>
            <a href="javascript:void(0);" class="btn" id="tip-btn">给其他楼幢缴电费</a>
        </div>
    </div>
	</if>
</div>
<input type="hidden" value="{BEESCRM:$ecs_id}" id="hsd-ecs">
<input type="hidden" value="0" id="flag">
<include file="commonJS" />
<script src="/assets/base/common/ajaxgetroominfo.js?v={BEESCRM:$time}"></script>
<script>
    
    function removeChecked() {
        $('.sub-list').removeClass('checked');
        $('#flag').val(1);
    }
    
    $('.icon-caidan-copy').click(function(e){
        $('.sub-menu').toggleClass('show');
        e.stopPropagation();
    })
    $(document).click(function(){
        $('.sub-menu').removeClass('show');
    })
	$('.scrm-loadding').show();
	$(function(){
		//调用房间联动js
		ajaxgetroominfo(true,true,true);
        var room_id = "{BEESCRM:$room_id}";
		//ajax请求剩余电量信息
		$.ajax({
			url: "/base/ecs/getInfo/ecs_id/"+{BEESCRM:$ecs_id},
			type: "post",
            data:{room_id:room_id},
			dataType: 'json',
			async: false,
			success: function (data) {
				if(data.status == 'S'){
					var hsd = $("#hsd-ecs").val();

						if(data.ele > 0){
							if(data.type == 1){
								var str = '<p class="warnimg">截至'+data.time+'剩余电量</p>'
										+'<p class="odd">'+data.ele+'度</p>';
							}else{
								var str = '<p class="warnimg">截至'+data.time+'剩余金额</p>'
										+'<p class="odd">'+data.ele+'元</p>';
							}
						}else{
							if(data.type == 1){
								var str = '<p class="warnimg">截至'+data.time+'剩余电量:'+data.ele+'度</p>';
							}else{
								var str = '<p class="warnimg">截至'+data.time+' <br />剩余金额:'+data.ele+'元</p>';
							}

						}
					}


				$('.eleInfo').html(str);
				$('.scrm-loadding').hide();
			}
		});
	});

	$('.tab-prize').on('click','.option',function(){
		if($(this).hasClass('other')){
            $('#flag').val(0);
			$(this).siblings().removeClass('checked');
			$(this).addClass('checked');
		}
		else{
            $('#flag').val(0);
			$(this).toggleClass('checked').siblings().removeClass('checked');
		}
	});

    $('.tab-prize').on('click','.sub-list',function(){
	    var str = '{BEESCRM:$str}';
	    $('.tab-prize #number').html(str);
    });

    /*提交订单*/
    $(document).on('click','.save',function(){
        var room = $('#room').val();
        var flag = $('#flag').val();
        var buildingId = $('#building').val();
        if(flag==1){
            money = $('#other').val();
            if(money == 0 || money== ''){
                $.layeralert('请输入有效金额');
                return false;
            }else if(money>100){
                $.layeralert('最大限额为100,请重新输入');
                return false;
            }
        }else{
            var money = $('.checked').data('amount');
        }


        var order_price = 0;

        if(!room){
            $.alert('error','请选择寝室');
            return false;
        }

        if(money > 0){
            order_price = money;
        }else{
            $.layeralert('请选择充值金额');
            return false;
        }

        if(order_price == 0){
            $.layeralert('请选择充值金额');
            return false;
        }

        if(buildingId == 74 || buildingId == 68 || buildingId == 69 || buildingId == 76 || buildingId == 65 || buildingId== 77 || buildingId==78 || buildingId== 79 || buildingId==80 || buildingId==81 || buildingId==82 || buildingId==83 || buildingId==84 || buildingId== 85 || buildingId==86 || buildingId== 87  || buildingId== 88 || buildingId== 89 || buildingId== 90 || buildingId==91 || buildingId==92 || buildingId==93 || buildingId==73 || buildingId==71 || buildingId==70 || buildingId==103 || buildingId==102){
            $.layeralert("B1-B10,C1-C12,A3-A7幢请到新系统中充值！");
            setTimeout('dump()',2000);
        }

        var info = {};
        info.room_id = room;
        info.order_amount = order_price;
        info.flag = 1;
        $.ajax({
            'url': "/base/ecs/index/ecs_id/{BEESCRM:$ecs_id}",
            'data': info,
            'dataType':'json',
            'type': 'POST',
            'async': false,
            success: function(data) {
                if (data.status == 'S') {
                    window.location.href=data.url;
                }else{
                    $.layeralert(data.message);
                    return false;
                }
            }
        });
    });

    $(document).on('click','#tip-btn',function(){
	    $('.pop-box').hide();
    })

    $(document).on('change','#building',function(){
	   var buildingId = $(this).val();
	    if(buildingId == 74 || buildingId == 68 || buildingId == 69 || buildingId == 76 || buildingId == 65 || buildingId== 77 || buildingId==78 || buildingId== 79 || buildingId==80 || buildingId==81 || buildingId==82 || buildingId==83 || buildingId==84 || buildingId== 85 || buildingId==86 || buildingId== 87  || buildingId== 88  || buildingId== 90 || buildingId==91 || buildingId==92 || buildingId==93 || buildingId==73 || buildingId==71 || buildingId==70 || buildingId==103 || buildingId==102){
		    $.layeralert("B1-B10,C1-C12,A3-A7幢请到新系统中充值！");
		    setTimeout('dump()',2000);
	    }
    })
    $(document).on('click','.hsd-close',function(){
	    $.layeralert("系统升级中，暂停查询功能！");
    })
	function dump(){
		window.location.href='/base/ips/index/ips_id/8';
	}
</script>
</body>
</html>